package com.some.jobdescapp.model;

import android.support.annotation.NonNull;
import android.view.View;

import com.randy.recyclerviews.adapter.UniversalAdapter;
import com.some.jobdescapp.R;
import com.some.jobdescapp.widget.PhotoPager;

import java.util.ArrayList;
import java.util.List;

/**
 * @author RANDY.ZHANG
 * @version 1.0
 * @company:
 * @date 2019/1/8 22:05
 */
public class BannerModel extends UniversalAdapter.AbstractModel<BannerModel.ViewHolder> {
    @Override
    public int getLayoutRes() {
        return R.layout.layout_banner_model;
    }

    @Override
    public void bindData(@NonNull ViewHolder holder) {
        super.bindData(holder);
        List<Integer> ids = new ArrayList<>();
        ids.add(R.drawable.image_1);
        ids.add(R.drawable.image_2);
        ids.add(R.drawable.image_3);
        ids.add(R.drawable.image_4);
        holder.photoPager.refreshViewByIds(ids, true);
    }

    @NonNull
    @Override
    public UniversalAdapter.IViewHolderCreator<ViewHolder> getViewHolderCreator() {
        return new UniversalAdapter.IViewHolderCreator<ViewHolder>() {
            @NonNull
            @Override
            public ViewHolder create(@NonNull View view) {
                return new ViewHolder(view);
            }
        };
    }

    public class ViewHolder extends UniversalAdapter.ViewHolder {
        private PhotoPager photoPager;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            photoPager = itemView.findViewById(R.id.photo_pager);
            photoPager.init();
        }
    }
}
